<%@ page import="beans.Vehicle" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>编辑车辆信息</title>
    <style>
        .action-btn {
            display: inline-block;
            margin-bottom: 20px;
            padding: 8px 15px;
            background-color: var(--secondary-color);
            color: white;
            text-decoration: none;
            border-radius: var(--border-radius);
            transition: background-color 0.3s ease;
        }

        .action-btn:hover {
            background-color: #5a6268;
        }
        body { font-family: 'Microsoft YaHei', Arial, sans-serif; background: #f6f6f6; }
        .form-container { background: #fff; max-width: 600px; margin: 40px auto; padding: 30px; border-radius: 8px; box-shadow: 0 2px 8px #eee; }
        .form-title { font-size: 2rem; color: #183a8a; text-align: center; margin-bottom: 30px; }
        .form-group { margin-bottom: 18px; }
        .form-group label { display: block; margin-bottom: 6px; font-weight: bold; }
        .form-group input, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; }
        .form-actions { text-align: center; margin-top: 30px; }
        .btn { padding: 10px 30px; border: none; border-radius: 4px; background: #183a8a; color: #fff; font-size: 1rem; cursor: pointer; }
        .btn:hover { background: #2450a7; }

    </style>
</head>
<%
    Vehicle vehicle = (Vehicle)request.getAttribute("vehicle");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    if (vehicle == null) {
%>
<div style="color:red;text-align:center;margin-top:40px;">未找到该车辆信息！</div>
</body>
</html>
<%
        return;
    }
%>
<body>
<div class="form-container">
    <a href="VehiclesServlet?action=all" class="action-btn">返回列表</a>
    <div class="form-title">编辑车辆信息</div>
    <form action="VehiclesServlet" method="post">
        <input type="hidden" name="action" value="edit1">
        <input type="hidden" name="vehicleId" value="<%= vehicle.getVehicleId() %>">

        <div class="form-group">
            <label for="licensePlate">车牌号</label>
            <input type="text" id="licensePlate" name="licensePlate" value="<%= vehicle.getLicensePlate() %>" required>
        </div>
        <div class="form-group">
            <label for="brandModel">品牌型号</label>
            <input type="text" id="brandModel" name="brandModel" value="<%= vehicle.getBrandModel() %>" required>
        </div>
        <div class="form-group">
            <label for="color">颜色</label>
            <input type="text" id="color" name="color" value="<%= vehicle.getColor() %>" required>
        </div>
        <div class="form-group">
            <label for="purchaseDate">购买日期</label>
            <input type="date" id="purchaseDate" name="purchaseDate" value="<%= sdf.format(vehicle.getPurchaseDate()) %>" required>
        </div>
        <div class="form-group">
            <label for="status">状态</label>
            <select id="status" name="status">
                <option value="空闲" <%= "空闲".equals(vehicle.getStatus()) ? "selected" : "" %>>空闲</option>
                <option value="使用" <%= "使用".equals(vehicle.getStatus()) ? "selected" : "" %>>使用</option>
            </select>
        </div>
        <div class="form-group">
            <label for="number">座位数</label>
            <input type="number" id="number" name="number" value="<%= vehicle.getNumber() %>" required>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn">提交修改</button>
        </div>
    </form>
</div>
</body>
</html> 